#! /usr/bin/env perl
# author: maxiao
# date: 2023-03-09 14:03
# description: 测试redo操作符对循环体的影响

use v5.20;
use strict;
use utf8;
use warnings;

# 打字测试
my @words = qw{ fred barney pebbles dino wilma betty };
my $errors = 0;

foreach (@words) {
    print "Type the word '$_': ";
    chomp(my $try = <STDIN>);
    if ( $try ne $_ ) {
        print "Sorry - That's not right.\n\n";
        $errors++;
        redo;   # 返回到循环块顶端，重新执行本次迭代
    }
}
print "You've completed the test, with $errors errors.\n";


